<%--
  Created by IntelliJ IDEA.
  User: 13095
  Date: 2024/9/18
  Time: 12:16
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set value="${pageContext.request.contextPath}" var="path"></c:set>
<html>
<head>
    <meta charset="UTF-8">
    <title>我的接单记录</title>
    <script src="${path}/static/js/jquery-3.2.1.min.js"></script>
    <link rel="stylesheet" href="${path}/static/css/staffcss.css">
    <script src="${path}/static/js/script.js"></script>
</head>
<body>
<div class="container">
    <header>
        <h1>进行中订单</h1>
        <jsp:include page="inc/inc.jsp"></jsp:include>
    </header>
    <main>
        <c:if test="${empty requestScope.ordersPageInfo.list}">
            <p>目前没有进行中的订单。</p>
        </c:if>
        <c:if test="${not empty requestScope.ordersPageInfo.list}">
            <table id="orderTable">
                <tr>
                    <th>订单编号</th>
                    <th>描述</th>
                    <th>状态</th>
                    <th>地点</th>
                    <th colspan="2">操作</th>
                </tr>
                <c:forEach items="${requestScope.ordersPageInfo.list}" var="order">
                    <tr>
                        <td>${order.orderNumber}</td>
                        <td>${order.task.description}</td>
                        <td>${order.status == 1? "去拿物品" : "去往送达物品"}</td>
                        <td>
                            <c:if test="${order.status == 1}">${order.task.location}</c:if>
                            <c:if test="${order.status == 2}">${order.task.useraddress.address}</c:if>
                        </td>
                        <td><a href="${path}/runner/detail?id=${order.id}&status=${order.status}"
                               title="查看订单详情">订单详情</a></td>
                        <td>
                            <c:if test="${order.status == 1}">
                                <a href="${path}/runner/goDelivery?id=${order.id}" title="开始配送此订单">去配送</a>
                            </c:if>
                            <c:if test="${order.status == 2}">
                                <a href="${path}/runner/complete?id=${order.id}" title="完成此订单">完成</a>
                            </c:if>
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </c:if>
        <!-- 分页导航开始 -->
        <div class="pagination">
            <c:if test="${requestScope.ordersPageInfo.hasPreviousPage}">
                <a href="${path}/runner/taskingList?page=${requestScope.ordersPageInfo.pageNum - 1}" title="上一页">上一页</a>
            </c:if>
            <c:forEach begin="1" end="${requestScope.ordersPageInfo.pages}" var="pageNum">
                <c:choose>
                    <c:when test="${pageNum == requestScope.ordersPageInfo.pageNum}">
                        <span class="current-page" title="当前页：${pageNum}">${pageNum}</span>
                    </c:when>
                    <c:otherwise>
                        <a href="${path}/runner/taskingList?page=${pageNum}" title="跳转到第 ${pageNum} 页">${pageNum}</a>
                    </c:otherwise>
                </c:choose>
            </c:forEach>
            <c:if test="${requestScope.ordersPageInfo.hasNextPage}">
                <a href="${path}/runner/taskingList?page=${requestScope.ordersPageInfo.pageNum + 1}" title="下一页">下一页</a>
            </c:if>
        </div>
        <!-- 分页导航结束 -->
    </main>
</div>
</body>
</html>